import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
import java.util.Scanner;

public class Calendario {
	public static Date sumarDia(Date fecha, int dias) {
		Calendar cal = Calendar.getInstance();
		cal.setTime(fecha);
		cal.add(Calendar.DATE, dias);
		return cal.getTime();
	}

	public static int getDayMonth(Calendar cal) {
		return cal.get(Calendar.DAY_OF_MONTH);
	}

	public static int getDayWeek(Calendar cal) {
		return cal.get(Calendar.DAY_OF_WEEK);
	}

	public static String diaToString(Calendar cal) {
		if (cal.get(Calendar.DAY_OF_MONTH) < 10)
			return cal.get(Calendar.DAY_OF_MONTH) + " ";
		else
			return Integer.toString(cal.get(Calendar.DAY_OF_MONTH));
	}

	public static boolean ultDiaMes(Calendar cal) {

		return (cal.get(Calendar.DAY_OF_MONTH) == cal
				.getActualMaximum(Calendar.DAY_OF_MONTH));
	}

	public static void mostrarMes(int anio, int mes) {
		Calendar cal = Calendar.getInstance();
		cal.set(anio, mes, 1);
		cal.set(Calendar.SUNDAY, 8);
		int mesActual = cal.get(Calendar.MONTH);

		// Date fecha = new Date (anio,mes,1 );
		System.out.println(" "
				+ cal.getDisplayName(Calendar.MONTH, Calendar.LONG,
						Locale.getDefault()));
		System.out.println("L M X J V S D");
		System.out.println("-------------------");

		do {
			for (int i = 1; mesActual == cal.get(Calendar.MONTH) && i < 8; i++) {

				if (getDayWeek(cal) == i) {
					System.out.print(diaToString(cal) + " ");
					cal.add(Calendar.DATE, 1);
				} else {
					System.out.print(" ");
				}

			}
			System.out.println("");

		} while (cal.get(Calendar.MONTH) == mesActual);

	}

	public static void main(String[] args) {

		for (int i = 0; i < 12; i++) {
			mostrarMes(2013, i);
			System.out.println("");

		}
	}
}
